package com.lyc.shopping_mall.mapper;


import com.lyc.shopping_mall.dto.ProductWithCategoryName;
import com.lyc.shopping_mall.pojo.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {


    //查询所有商品
    @Select("select * from product")
    List<Product> getAllProduct();

    //查询adimg字段不为空的商品
    @Select("select * from product where adimg is not null")
    List<Product> getAdProduct();

    //根据分类查询商品，连表查询，查询商品和分类信息
    @Select("select p.*,c.name from product p,category c where p.categoryid=c.categoryid and c.name=#{name}")
    List<ProductWithCategoryName> getProductByCategory(String name);
}
